package com.ray.controller;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ray.bean.CustomerBean;
import com.ray.bean.DatatablesViewPageBean;
import com.ray.bean.DepartmentBean;
import com.ray.bean.MaterialBean;
import com.ray.bean.OrderInfoTemplateBean;
import com.ray.bean.PersonBean;
import com.ray.exception.ServiceException;
import com.ray.mapper.OrderCreateMapper;
import com.ray.pojo.MyUser;
import com.ray.service.BasicDataService;
import com.ray.service.OrderCreateService;
import com.ray.service.OrderInfoTemplateService;
import com.ray.util.QrcodeUtilsZxing;
import com.ray.util.RequestUtil;
import com.ray.util.ResponseUtil;
import com.ray.util.UploadFilesUtil;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import com.sun.org.apache.bcel.internal.generic.NEW;

/**
 * 工具请求
 * @author Shensg
 * 2018年1月24日
 */

@SuppressWarnings("unused")
@RestController
@RequestMapping("/utils")
public class UtilsController {
	/**
	 * zxing生产二维码 以流形式返回
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws ServiceException
	 */
	@RequestMapping("/qrcode")
	public void deleteOrderInfoPrimary(HttpServletRequest request,HttpServletResponse response) throws IOException, ServiceException  {  
		Map map=RequestUtil.getRequestAllParam(request);
		ByteArrayOutputStream output = new ByteArrayOutputStream();  
        QrcodeUtilsZxing.zxingCodeCreate(map.get("qrcode_url").toString(), 1000, 1000, output, "png"); 
        try {  
            ServletOutputStream out = response.getOutputStream();  
            output.writeTo(out);  
        } catch (IOException e) {  
            e.printStackTrace();  
        } 
	}
}
